import { createI18n } from 'vue-i18n'
import en from './locales/en'
import zh from './locales/zh'

// 简单的语言检测
const getDefaultLanguage = () => {
  const saved = localStorage.getItem('language')
  if (saved) return saved
  return navigator.language.includes('zh') ? 'zh' : 'en'
}

// 创建i18n实例
const i18n = createI18n({
  legacy: false,
  globalInjection: true,
  locale: getDefaultLanguage(),
  messages: {
    en,
    zh
  }
})

export default i18n
